#pragma once
#ifndef SYPX_AUDIOENGINEOAL
#define SYPX_AUDIOENGINEOAL

#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#include "Base.h"
#include "AudioEngine.h"


namespace SypX
{
	class AudioEngineOAL : public AudioEngine
	{
	public:
		AudioEngineOAL(void);
		virtual ~AudioEngineOAL(void);
		///Initialises a soundbuffer and returns the bufferID. (Not to be called by User)
		UInt createSoundBuffer();
		///Deletes the soundbuffer in Sound memory (Not to be called by User)
		void deleteSoundBuffer(SoundBuffer* snd);
		///Loads a wav file and returns it in a SoundBuffer
		SoundBuffer* loadFromWAVFile(const String& name);
		///Plays the sound from SoundBuffer at pos
		virtual void playSound(SoundBuffer* snd, const Vec3& pos );
		///Sets the position of the listener
		void setListenerPos(const Vec3& pos);	
		///Plays a background music file (Only works on iPhone for now)
		///Due to hardware constraints on iPhone, only 1 background music can be played by hardware
		///All sound effects should use SoundBuffers and playSound
		virtual void playMusic(const String& file, bool loop = true);
		///Stops currently playing Music
		virtual void stopMusic();
	private:
		void init();
		static const UInt NUMSOURCES = 3;
		UInt source[NUMSOURCES];
		ALCcontext* context;
		ALCdevice* device;
		
	};
}
#endif